package com.cmict.data.infra.api.message;

import com.cmict.data.infra.api.emus.ApiConstants;
import com.cmict.data.infra.api.message.dto.MessageDTO;
import com.cmict.data.infra.service.message.MessageTemplateService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@DubboService(version = ApiConstants.VERSION)
@Validated
public class MessageSendApiImpl implements MessageSendApi {

    @Resource
    private MessageTemplateService messageTemplateService;

    @Override
    public Boolean sendMessageByTemplate(MessageDTO messageDTO) {
        return messageTemplateService.sendMessageByTemplate(messageDTO);
    }

    @Override
    public Long getTemplateByTitle(String title) {
      String regTitle =  title.replaceAll("[<>()/]", "");
        return messageTemplateService.getTemplateByTitle(regTitle);
    }



}
